package com.oa.srms.apps.business.limit.impl;

import org.springframework.beans.factory.annotation.Autowired;

import com.oa.srms.apps.business.limit.IPostLimitService;
import com.oa.srms.apps.dao.limit.IPostLimitDao;
import com.oa.srms.apps.entity.limit.PostLimitValue;

public class PostLimitServiceImpl implements IPostLimitService {
	@Autowired
	private PostLimitValue postLimit;
	@Autowired
	private IPostLimitDao postLimitDao;

	@Override
	public boolean addOrModifyPostLimit(int postId, String limitIds) throws Exception {
		postLimit.setPostId(postId);
		postLimit.setLimitIds(limitIds);
		return postLimitDao.addOrModifyPostLimit(postLimit);
	}

	@Override
	public boolean deletePostLimit(int postId) throws Exception {
		postLimit = queryByPostId(postId);
		if(postLimit != null){
			return postLimitDao.deletePostLimit(postLimit);
		}
		return false;
	}

	@Override
	public PostLimitValue queryByPostId(int postId) throws Exception {
		postLimit.setPostId(postId);
		return postLimitDao.queryByPostId(postLimit);
	}
	
}
